package com.cy.ppj.service.netpoint.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cy.ppj.dao.mapper.netpoint.NetPointMapper;
import com.cy.ppj.model.PageBean;
import com.cy.ppj.model.domian.netpoint.NetPoint;
import com.cy.ppj.model.query.netpoint.NetPointAdminQuery;
import com.cy.ppj.model.vo.admin.netpoint.NetPointAdminVO;
import com.cy.ppj.service.BaseService;
import com.cy.ppj.service.netpoint.NetPointService;

/**
 * 网点管理
 *
 * @author: tanyilin
 * @create: 2018年10月12日 下午5:19:30
 */
@Service
public class NetPointServiceImpl extends BaseService implements NetPointService{

	@Autowired
	private NetPointMapper netPointMapper;

	@Override
	@Transactional
	public void addNetPoint(NetPoint netPoint) {
		Date time = new Date();
		netPoint.setCreateTime(time);
		netPoint.setUpdateTime(time);
		netPointMapper.insertSelective(netPoint);
	}

	@Override
	@Transactional
	public void updateNetPoint(NetPoint netPoint) {
		netPoint.setUpdateTime(new Date());
		netPointMapper.updateByPrimaryKeySelective(netPoint);
	}

	@Override
	@Transactional
	public void deleteNetPoint(NetPoint netPoint) {
		netPointMapper.delete(netPoint);
	}

	@Override
	public PageBean<NetPointAdminVO> selectNetPointAdminList(NetPointAdminQuery query) {
		int total = netPointMapper.selectNetPointAdminCount(query);
		List<NetPointAdminVO> list = new ArrayList<>();
		if(total > 0) {
			query.startPage();
			list = netPointMapper.selectNetPointAdminList(query);
		}
		return new PageBean<>(list, total);
	}
	
	
	
}
